{include file='head'/}
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <table id="admin_table" lay-filter="admin_table"></table>
    </div>
</div>
<script type="text/html" id="return_codeTpl">
    {{#  if(d.return_code =='0'){ }}
    <span class="layui-badge layui-bg-green"> 执行成功 </span>
    {{#  } else { }}
    <span class="layui-badge layui-bg-danger"> 执行失败 </span>
    {{#  } }}
</script>

{include file='footer'/}
<script>
  layui.use(['table', 'jquery'], function () {
    var $ = layui.jquery;
    var table = layui.table;

    table.render({
      elem: '#admin_table'
      , toolbar: '#add_toolbar'
      , defaultToolbar: [{
        layEvent: 'refresh',
        icon: 'layui-icon-refresh',
        title: '刷新'
      }, 'filter', 'exports']
      , method: 'get'
      , where: {crontab_id:"{$crontab_id}"}
      , url: "{:__url('system/crontab/log_list')}"
      , parseData: function (res) {
        return {
          "code": res.code_lay,
          "msg": res.msg,
          "count": res.count,
          "data": res.data
        };
      }
      , cellMinWidth: 100
      , cols: [[
        {field: 'id', title: 'ID', width: 60, align: 'center'}
        , {field: 'target', title: '任务调用字符串'}
        , {field: 'return_code', title: '返回状态', width: 100, align: 'center',templet: '#return_codeTpl'}
        , {field: 'running_time', title: '执行所用时间', align: 'center', width: 120}
        , {field: 'create_time', title: '执行时间', width: 160, align: 'center'}
      ]]
      , id: 'testReload'
      , page: true
      , limit: 10
    });
    var $ = layui.$, active = {
      reload: function () {
        //执行重载
        table.reload('testReload', {
          page: {curr: 1},
          where: {
            key: {
              title: $('#title').val(),
              status: $('#isuse').val(),
            }
          }
        });
      }
    };


    //监听行工具事件
    table.on('toolbar(admin_table)', function (obj) {
      if (obj.event === 'refresh') {
        table.reload('testReload');
      }
    });

  });
</script>
</body>
</html>
